package edu.upenn.seas.peerreview.smui

import scala.collection.mutable
import edu.upenn.seas.peerreview.{Id, Sink}

class BSNameServer(myId:Id, t:Sink.T) extends BSHandler(myId, t) {
  protected val registered : mutable.Map[String, Id] = mutable.Map()

  def handle (e: Envelope) { 
    val from = e.from
    e.contents match {  
      case RegisterTournament(name) => registered(name) = from
      case RequestId(name) => registered.get(name) match {
        case None => {}// TODO: fail, no such tournament.
        case Some(i) => send(from, ReturnId(i))
        }
      case _ => // Ignore message. TODO: remove tournament?
    }
  }     
}

